package com.google.code.virtualhockey.vhx.server.servlet.rest

import javax.servlet.http.HttpServletResponse

/**
 * Indicates that there is a problem with the currently processed REST command.
 */
class RestCommandException( msg: String, cause: Throwable ) extends RuntimeException( msg, cause ) {

  /** The HTTP error status code that should be sent back to the client. */
  val httpStatusCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR

  /**
   * Alternative constructor that allows creating a RestCommandException using only an error
   * message but no root cause Throwable.
   */
  def this( msg: String ) = this( msg, null )

  /**
   * Returns a list of additional JSON attributes that should be included into any error response which
   * is sent back to the client following a raise of this exception.
   */
  def getAdditionalResponseAttributes: List[String] = Nil
}
